package com.pet_service.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.pet_service.util.CodeEnum;

/**
 * 通用审核状态枚举
 * 用于各种需要审核功能的业务场景
 */
public enum AuditStatus implements CodeEnum {
    PENDING(0, "待审核"),
    APPROVED(1, "通过"),
    REJECTED(2, "拒绝");

    @EnumValue
    private final int code;
    private final String desc;

    AuditStatus(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public int getCode() { return code; }
    public String getDesc() { return desc; }

    /**
     * 根据code获取对应的枚举值
     */
    public static AuditStatus fromCode(int code) {
        for (AuditStatus status : values()) {
            if (status.getCode() == code) {
                return status;
            }
        }
        throw new IllegalArgumentException("No matching AuditStatus for code: " + code);
    }
}
